var realtimeBoard = function() {
	var boardType1;
	var boardType2;
	var boardType3;
	var boardType4;
	var boardTypeArr = ["SOC,1","总电压,2","总电流,3","单体最高电压,4","单体最低电压,5","监测点最高温度,6","监测点最低温度,7"];
	var packCodeArr = new Array();
	return {
		/**
		 * 页面初始化方法
		 */
		init: function() {

			realtimeBoard._getPackCodeList();
			//看板实时数据请求定时器
			board1RefreshCount = 0;
			board2RefreshCount = 0;
			board3RefreshCount = 0;
			board4RefreshCount = 0;
			//初始化页面，清空定时器
			if(board1RefreshTimer) {
				window.clearInterval(board1RefreshTimer);
			}
			if(board2RefreshTimer) {
				window.clearInterval(board2RefreshTimer);
			}
			if(board3RefreshTimer) {
				window.clearInterval(board3RefreshTimer);
			}
			if(board4RefreshTimer) {
				window.clearInterval(board4RefreshTimer);
			}
			
			//声明看板变量1
			var board1 = "board1";
			boardType1 = $("#boardType1").attr("data-type");
			//看板为图表则先初始化图表
			if( boardType1 !="0" ) {
				board1 = echarts.init(document.getElementById(board1),'macarons');
			}
			//初始化看板
			board1RefreshTimer = realtimeBoard._initBoard(true,boardType1,board1,board1RefreshTimer);

			//声明看板变量2
			var board2 = "board2";
			boardType2 = $("#boardType2").attr("data-type");
			//看板为图表则先初始化图表
			if( boardType2 !="0" ) {
				board2 = echarts.init(document.getElementById(board2),'macarons');
			}
			//初始化看板
			board2RefreshTimer = realtimeBoard._initBoard(true,boardType2,board2,board2RefreshTimer);

			//声明看板变量3
			var board3 = "board3";
			boardType3 = $("#boardType3").attr("data-type");
			//看板为图表则先初始化图表
			if( boardType3 !="0" ) {
				board3 = echarts.init(document.getElementById(board3),'macarons');
			}
			//初始化看板
			board3RefreshTimer = realtimeBoard._initBoard(true,boardType3,board3,board3RefreshTimer);

			//声明看板变量4
			var board4 = "board4";
			boardType4 = $("#boardType4").attr("data-type");
			//看板为图表则先初始化图表
			if( boardType4 !="0" ) {
				board4 = echarts.init(document.getElementById(board4),'macarons');
			}
			//初始化看板
			board4RefreshTimer = realtimeBoard._initBoard(true,boardType4,board4,board4RefreshTimer);



			//点击其他区域remove select frame
			$(".batteryBorder-container").click(function() {
				$(".select-frame").remove();
			});

			/*
			 *监控状态的切换
			 * 默认状态为开始
			 * 加上.stop类名即为停止状态
			 */
			/*$(".parm-select .status").click(function() {
				if ($(this).hasClass("stop")) {
					$(this).removeClass("stop");
				} else {
					$(this).addClass("stop");
				}
			});*/

			$("#boardstatus1").on('click', function(event) {
				if ($(this).hasClass("stop")) {
					$(this).removeClass("stop");
					if(board1RefreshTimer) {
						window.clearInterval(board1RefreshTimer);
					}
				} else {
					$(this).addClass("stop");
					if(board1RefreshTimer) {
						window.clearInterval(board1RefreshTimer);
					}
					//初始化看板
					board1RefreshTimer = realtimeBoard._initBoard(false,boardType1,board1,board1RefreshTimer);
				}

			});

			$("#boardstatus2").on('click', function(event) {
				if ($(this).hasClass("stop")) {
					$(this).removeClass("stop");
					if(board2RefreshTimer) {
						window.clearInterval(board2RefreshTimer);
					}
				} else {
					$(this).addClass("stop");
					if(board2RefreshTimer) {
						window.clearInterval(board2RefreshTimer);
					}
					//初始化看板
					board2RefreshTimer = realtimeBoard._initBoard(false,boardType2,board2,board2RefreshTimer);
				}

			});

			$("#boardstatus3").on('click', function(event) {
				if ($(this).hasClass("stop")) {
					$(this).removeClass("stop");
					if(board3RefreshTimer) {
						window.clearInterval(board3RefreshTimer);
					}
				} else {
					$(this).addClass("stop");
					if(board3RefreshTimer) {
						window.clearInterval(board3RefreshTimer);
					}
					//初始化看板
					board3RefreshTimer = realtimeBoard._initBoard(false,boardType3,board3,board3RefreshTimer);
				}

			});

			$("#boardstatus4").on('click', function(event) {
				if ($(this).hasClass("stop")) {
					$(this).removeClass("stop");
					if(board4RefreshTimer) {
						window.clearInterval(board4RefreshTimer);
					}
				} else {
					$(this).addClass("stop");
					if(board4RefreshTimer) {
						window.clearInterval(board4RefreshTimer);
					}
					//初始化看板
					board4RefreshTimer = realtimeBoard._initBoard(false,boardType4,board4,board4RefreshTimer);
				}

			});

			
			//看板1切换
			$("#boardType1").on('click', function(e) {
				var _self = $(this);
				e.stopPropagation();
				$(".select-frame").remove();
				var w = $(this).width()+15;
				var offset = $(this).offset();
				var selectbox = $("<ul class='select-frame' id='board1frame'></ul>");
				for (var i = 0; i < boardTypeArr.length; i++) {
					selectbox.append("<li data-type='"+boardTypeArr[i].split(",")[1] +"'>" + boardTypeArr[i].split(",")[0] + "</li>");
				}
				$("body").append(selectbox);
				$(".select-frame").css({
					width: w + "px",
					top: offset.top - 10 + "px",
					left: offset.left + "px"
				});
				$("#board1frame li").click(function() {
					var _text = $(this).text();
					_self.text(_text);
					_self.attr('data-type', $(this).attr("data-type"));
					var _boardType1 = $(this).attr("data-type");
					console.log(_boardType1);
					//转换看板显示内容时先清空定时器
					if (board1RefreshTimer) {
						console.log("清除定时器board1RefreshTimer:" + board1RefreshTimer);
						window.clearInterval(board1RefreshTimer);
					}
					//若转换前为echart实例,需要销毁echart实例
					if (boardType1 != "0") {
						//清除之前的实例
						board1.dispose();
					}
					//若change后为echart看板，需要先初始化echart实例
					if (_boardType1 != "0") {
						//重新初始化echart看板
						board1 = echarts.init(document.getElementById("board1"),'macarons');
					} else {
						board1 = "board1";
					}
					//记录当前看板的显示的类型echart或者是bmap
					boardType1 = _boardType1;
					//初始化看板
					board1RefreshTimer = realtimeBoard._initBoard(true,boardType1, board1, board1RefreshTimer);
					$(".select-frame").remove();
				});
			});


			//看板2切换
			$("#boardType2").on('click', function(e) {
				var _self = $(this);
				e.stopPropagation();
				$(".select-frame").remove();
				var w = $(this).width()+15;
				var offset = $(this).offset();
				var selectbox = $("<ul class='select-frame' id='board2frame'></ul>");
				for (var i = 0; i < boardTypeArr.length; i++) {
					selectbox.append("<li data-type='"+boardTypeArr[i].split(",")[1] +"'>" + boardTypeArr[i].split(",")[0] + "</li>");
				}
				$("body").append(selectbox);
				$(".select-frame").css({
					width: w + "px",
					top: offset.top - 10 + "px",
					left: offset.left + "px"
				});
				$("#board2frame li").click(function() {
					var _text = $(this).text();
					_self.text(_text);
					_self.attr('data-type', $(this).attr("data-type"));
					var _boardType2 = $(this).attr("data-type");
					console.log(_boardType2);
					//转换看板显示内容时先清空定时器
					if (board2RefreshTimer) {
						console.log("清除定时器board2RefreshTimer:" + board2RefreshTimer);
						window.clearInterval(board2RefreshTimer);
					}
					//若转换前为echart实例,需要销毁echart实例
					if (boardType2 != "0") {
						//清除之前的实例
						board2.dispose();
					}
					//若change后为echart看板，需要先初始化echart实例
					if (_boardType2 != "0") {
						//重新初始化echart看板
						board2 = echarts.init(document.getElementById("board2"),'macarons');
					} else {
						board2 = "board2";
					}
					//记录当前看板的显示的类型echart或者是bmap
					boardType2 = _boardType2;
					//初始化看板
					board2RefreshTimer = realtimeBoard._initBoard(true,boardType2, board2, board2RefreshTimer);
					$(".select-frame").remove();
				});
			});

			//看板3切换
			$("#boardType3").on('click', function(e) {
				var _self = $(this);
				e.stopPropagation();
				$(".select-frame").remove();
				var w = $(this).width()+15;
				var offset = $(this).offset();
				var selectbox = $("<ul class='select-frame' id='board3frame'></ul>");
				for (var i = 0; i < boardTypeArr.length; i++) {
					selectbox.append("<li data-type='"+boardTypeArr[i].split(",")[1] +"'>" + boardTypeArr[i].split(",")[0] + "</li>");
				}
				$("body").append(selectbox);
				$(".select-frame").css({
					width: w + "px",
					top: offset.top - 10 + "px",
					left: offset.left + "px"
				});
				$("#board3frame li").click(function() {
					var _text = $(this).text();
					_self.text(_text);
					_self.attr('data-type', $(this).attr("data-type"));
					var _boardType3 = $(this).attr("data-type");
					console.log(_boardType3);
					//转换看板显示内容时先清空定时器
					if (board3RefreshTimer) {
						console.log("清除定时器board3RefreshTimer:" + board3RefreshTimer);
						window.clearInterval(board3RefreshTimer);
					}
					//若转换前为echart实例,需要销毁echart实例
					if (boardType3 != "0") {
						//清除之前的实例
						board3.dispose();
					}
					//若change后为echart看板，需要先初始化echart实例
					if (_boardType3 != "0") {
						//重新初始化echart看板
						board3 = echarts.init(document.getElementById("board3"),'macarons');
					} else {
						board3 = "board3";
					}
					//记录当前看板的显示的类型echart或者是bmap
					boardType3 = _boardType3;
					//初始化看板
					board3RefreshTimer = realtimeBoard._initBoard(true,boardType3, board3, board3RefreshTimer);
					$(".select-frame").remove();
				});
			});

			//看板4切换
			$("#boardType4").on('click', function(e) {
				var _self = $(this);
				e.stopPropagation();
				$(".select-frame").remove();
				var w = $(this).width()+15;
				var offset = $(this).offset();
				var selectbox = $("<ul class='select-frame' id='board4frame'></ul>");
				for (var i = 0; i < boardTypeArr.length; i++) {
					selectbox.append("<li data-type='"+boardTypeArr[i].split(",")[1] +"'>" + boardTypeArr[i].split(",")[0] + "</li>");
				}
				$("body").append(selectbox);
				$(".select-frame").css({
					width: w + "px",
					top: offset.top - 10 + "px",
					left: offset.left + "px"
				});
				$("#board4frame li").click(function() {
					var _text = $(this).text();
					_self.text(_text);
					_self.attr('data-type', $(this).attr("data-type"));
					var _boardType4 = $(this).attr("data-type");
					console.log(_boardType4);
					//转换看板显示内容时先清空定时器
					if (board4RefreshTimer) {
						console.log("清除定时器board4RefreshTimer:" + board4RefreshTimer);
						window.clearInterval(board4RefreshTimer);
					}
					//若转换前为echart实例,需要销毁echart实例
					if (boardType4 != "0") {
						//清除之前的实例
						board4.dispose();
					}
					//若change后为echart看板，需要先初始化echart实例
					if (_boardType4 != "0") {
						//重新初始化echart看板
						board4 = echarts.init(document.getElementById("board4"),'macarons');
					} else {
						board4 = "board4";
					}
					//记录当前看板的显示的类型echart或者是bmap
					boardType4 = _boardType4;
					//初始化看板
					board4RefreshTimer = realtimeBoard._initBoard(true,boardType4, board4, board4RefreshTimer);
					$(".select-frame").remove();
				});
			});

			//电池切换
			$("#packCode").on('click', function(e) {
				var _self = $(this);
				e.stopPropagation();
				$(".select-frame").remove();
				var w = $(this).width();
				var offset = $(this).offset();
				var selectbox = $("<ul class='select-frame' id='packCodeframe'></ul>");
				if(packCodeArr!=null&&packCodeArr.length>0){
					for (var i = 0; i < packCodeArr.length; i++) {
						selectbox.append("<li data-colclientid='"+packCodeArr[i].split(",")[1]+"'>" + packCodeArr[i].split(",")[0] + "</li>");
					}
				}
				$("body").append(selectbox);
				$(".select-frame").css({
					width: w + "px",
					top: offset.top - 10 + "px",
					left: offset.left + "px"
				});
				$("#packCodeframe li").click(function() {
					var _text = $(this).text();
					_self.text(_text);
					_self.attr('data-colclientid', $(this).attr('data-colclientid'));
					$(".select-frame").remove();
					//packCode change，清空定时器
					$(".parm-select .status").each(function(index, el) {
						if(!$(this).hasClass('stop')){
							$(this).addClass('stop');
						}
					});
					if(board1RefreshTimer) {
						window.clearInterval(board1RefreshTimer);
					}
					if(board2RefreshTimer) {
						window.clearInterval(board2RefreshTimer);
					}
					if(board3RefreshTimer) {
						window.clearInterval(board3RefreshTimer);
					}
					if(board4RefreshTimer) {
						window.clearInterval(board4RefreshTimer);
					}
					//初始化看板
					board1RefreshTimer = realtimeBoard._initBoard(true,boardType1,board1,board1RefreshTimer);
					//初始化看板
					board2RefreshTimer = realtimeBoard._initBoard(true,boardType2,board2,board2RefreshTimer);
					//初始化看板
					board3RefreshTimer = realtimeBoard._initBoard(true,boardType3,board3,board3RefreshTimer);
					//初始化看板
					board4RefreshTimer = realtimeBoard._initBoard(true,boardType4,board4,board4RefreshTimer);


				});
			});
			

		},

		/**
		 * 电池实时位置初始化
		 * 
		 */
		_getRealtimeLocation: function(divId) {
			var packCode = $("#packCode").text();
			var clientId = $('#packCode').attr('data-colclientid');
			$("#"+divId).empty(); //清空地图内容
			var map = new BMap.Map(divId);
			map.centerAndZoom(new BMap.Point(116.417854, 39.921988), 14); //默认中心点
			map.enableScrollWheelZoom(true); //缩放
			//向地图中添加缩放控件  
			var ctrlNav = new window.BMap.NavigationControl({
				anchor: BMAP_ANCHOR_TOP_LEFT,
				type: BMAP_NAVIGATION_CONTROL_LARGE
			});
			map.addControl(ctrlNav);
			//向地图中添加缩略图控件  
			var ctrlOve = new window.BMap.OverviewMapControl({
				anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
				isOpen: 1
			});
			map.addControl(ctrlOve);
			//向地图中添加比例尺控件  
			var ctrlSca = new window.BMap.ScaleControl({
				anchor: BMAP_ANCHOR_BOTTOM_LEFT
			});
			map.addControl(ctrlSca);
			var myIcon = new BMap.Icon("./media/image/point_icon.png", new BMap.Size(40, 45));
			//添加标注
			$.ajax({
				'type': 'post',
				'url': 'main/packDataMonitor/getCurrentLocationInfo.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode,
					'clientId': clientId
				},
				'success': function(data) {
					//清空上次标注
					map.clearOverlays();
					if (data && data.clientId != null) {
						var new_point = new BMap.Point(data.longitude, data.latitude);
						var marker = new BMap.Marker(new_point, {
							icon: myIcon
						}); // 创建标注
						var _facName = data.facName;
						_facName = data.facName == null ? '未关联厂区' : data.facName;
						var lableInfo = "<table><tr><td><b>最后采集时间：</b>" + data.gatherTime + "</td><td><b>采集终端ID：</b>" + data.clientId + "</td></tr>" +
							"<tr><td><b>电池ID：</b>" + data.packCode + "</td><td><b>SOC：</b>" + data.soc + "</td></tr>" +
							"<tr><td><b>总电压：</b>" + data.vol + "V</td><td><b>总电流：</b>" + data.current + "A</td></tr>" +
							"<tr><td><b>客户：</b>" + data.cusName + "</td><td><b>所属厂区：</b>" + _facName + "</td></tr>" +
							"<tr><td><b>地理位置：</b>" + data.address + "</td><td></td></tr>" +
							"</table>";
						var info = new window.BMap.InfoWindow(lableInfo);
						marker.addEventListener("mouseover", function() {
							this.openInfoWindow(info);
						});
						map.addOverlay(marker); // 将标注添加到地图中
						map.panTo(new_point);
					};

				},
				'error': function(msg) {
					console.log("error");
				}
			});
		},



		/**
		 * [_echartsConfig echarts定义]
		 * @param  {[type]} title      [标题]
		 * @param  {[type]} legendData [legendData]
		 * @param  {[type]} xAxisData  [xAxisData]
		 * @param  {[type]} yAxisName  [yAxisName]
		 * @param  {[type]} series     [series]
		 * @param  {[type]} myChart    [myChart]
		 * @return {[type]}            [description]
		 */
		_echartsConfig: function(title, legendData, unit,xAxisData, yAxisName, series, myChart,tooltipFormat) {
			var option = {
				//backgroundColor:'rgba(255,255,255,0.05)',
				/*title: {
					text: title,
					textStyle:{
			        	color: '#FFF'
			        }
				},*/
				tooltip: {
					trigger: 'axis',
					formatter:tooltipFormat
				},
				legend: {
					data: legendData,
					textStyle:{
			        	color: '#FFF'
					}
				},
				toolbox: {
					show: true,
					feature: {
						/*mark: {
							show: true
						},*/
						dataView: {
							show: true,
							readOnly: false
						},
						magicType: {
							show: true,
							type: ['line', 'bar']
						},
						restore: {
							show: true
						},
						saveAsImage: {
							show: true
						}
					}
				},
				dataZoom: {
					show: false,
					start: 0,
					end: 100
				},
				xAxis: [{
					type: 'category',
					boundaryGap: true,
					name: '时间',
					axisLabel:{
			          		show: true,
			          		textStyle:{
			          			color: '#FFF'
			          		}
			          	},
			        axisLine:{
                        lineStyle:{
                            color:'#FFF',
                        }
                    },
					data: xAxisData
				}],
				yAxis: [{
					type: 'value',
					scale: true,
					name: yAxisName,
					axisLabel:{
			          		show: true,
			          		textStyle:{
			          			color: '#FFF'
			          		},
							formatter: '{value}' + unit
			          	},
			        axisLine:{
                        lineStyle:{
                            color:'#FFF',
                        }
                    },
					boundaryGap: [0.2, 0.2],
					min: 0
				}],
				series: series
			};
			myChart.setOption(option);

		},

		/**
		 * [_echartsConfig echarts定义]
		 * @param  {[type]} title      [标题]
		 * @param  {[type]} legendData [legendData]
		 * @param  {[type]} xAxisData  [xAxisData]
		 * @param  {[type]} yAxisName  [yAxisName]
		 * @param  {[type]} series     [series]
		 * @param  {[type]} myChart    [myChart]
		 * @return {[type]}            [description]
		 */
		_echartsConfig2: function(title, legendData, unit,xAxisData, yAxisName, series, myChart,tooltipFormat) {
			var option = {
				//backgroundColor:'rgba(255,255,255,0.05)',
				/*title: {
					text: title,
					textStyle:{
			        	color: '#FFF'
			        }
				},*/
				tooltip: {
					trigger: 'axis',
					formatter:tooltipFormat
				},
				legend: {
					data: legendData,
					textStyle:{
			        	color: '#FFF'
					}
				},
				toolbox: {
					show: true,
					feature: {
						/*mark: {
							show: true
						},*/
						dataView: {
							show: true,
							readOnly: false
						},
						magicType: {
							show: true,
							type: ['line', 'bar']
						},
						restore: {
							show: true
						},
						saveAsImage: {
							show: true
						}
					}
				},
				dataZoom: {
					show: false,
					start: 0,
					end: 100
				},
				xAxis: [{
					type: 'category',
					boundaryGap: true,
					name: '时间',
					axisLabel:{
			          		show: true,
			          		textStyle:{
			          			color: '#FFF'
			          		}
			          	},
			        axisLine:{
                        lineStyle:{
                            color:'#FFF',
                        }
                    },
					data: xAxisData
				}],
				yAxis: [{
					type: 'value',
					scale: true,
					name: yAxisName,
					axisLabel:{
			          		show: true,
			          		textStyle:{
			          			color: '#FFF'
			          		},
							formatter: '{value}' + unit
			          	},
			        axisLine:{
                        lineStyle:{
                            color:'#FFF',
                        }
                    },
					boundaryGap: [0.2, 0.2]
				}],
				series: series
			};
			myChart.setOption(option);

		},

		/**
		 * [_echartsConfig echarts定义]
		 * @param  {[type]} title      [标题]
		 * @param  {[type]} legendData [legendData]
		 * @param  {[type]} xAxisData  [xAxisData]
		 * @param  {[type]} yAxisName  [yAxisName]
		 * @param  {[type]} series     [series]
		 * @param  {[type]} myChart    [myChart]
		 * @return {[type]}            [description]
		 */
		_currentEchartsConfig: function(title, legendData, unit,xAxisData, yAxisName, series, myChart,tooltipFormat) {
			var option = {
				//backgroundColor:'rgba(255,255,255,0.05)',
				/*title: {
					text: title,
					textStyle:{
			        	color: '#FFF'
			        }
				},*/
				tooltip: {
					trigger: 'axis',
					formatter:tooltipFormat
				},
				legend: {
					data: legendData,
					textStyle:{
			        	color: '#FFF'
					}
				},
				toolbox: {
					show: true,
					feature: {
						/*mark: {
							show: true
						},*/
						dataView: {
							show: true,
							readOnly: false
						},
						magicType: {
							show: true,
							type: ['line', 'bar']
						},
						restore: {
							show: true
						},
						saveAsImage: {
							show: true
						}
					}
				},
				dataZoom: {
					show: false,
					start: 0,
					end: 100
				},
				xAxis: [{
					type: 'category',
					boundaryGap: true,
					name: '时间',
					axisLabel:{
		          		show: true,
		          		textStyle:{
		          			color: '#FFF'
		          		}
		          	},
			        axisLine:{
                        lineStyle:{
                            color:'#FFF',
                        }
                    },
					data: xAxisData
				}],
				yAxis: [{
					type: 'value',
					scale: true,
					name: yAxisName,
					axisLabel:{
		          		show: true,
		          		textStyle:{
		          			color: '#FFF'
		          		},
						formatter: '{value}' + unit
		          	},
			        axisLine:{
                        lineStyle:{
                            color:'#FFF',
                        }
                    },  	
					boundaryGap: [0.2, 0.2]
				}],
				series: series
			};
			myChart.setOption(option);

		},


		/**
		 * 初始化soc图表
		 * @param  {[type]} myChart [description]
		 * @return {[type]}         [description]
		 */
		_initSocEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getSocData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "SOC";
					var legendData = ["soc"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "soc(%)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: 'soc',
						type: 'line',
						markPoint: {
							data: [{
								type: 'max',
								name: '最大值'
							}, {
								type: 'min',
								name: '最小值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._echartsConfig2(title, legendData,'%', xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}%');
				},
				'error': function(msg) {
					console.log("init soc echarts data error");
				}
			});
		},

		/**
		 * 初始化电流图表
		 * @param  {[type]} myChart [description]
		 * @return {[type]}         [description]
		 */
		_initCurrentEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getCurrentData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "总电流";
					var legendData = ["总电流"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "总电流(A)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: '总电流',
						type: 'line',
						markPoint: {
							data: [{
								type: 'max',
								name: '最大值'
							}, {
								type: 'min',
								name: '最小值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._currentEchartsConfig(title, legendData,'',xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}A');
				},
				'error': function(msg) {
					console.log("init soc echarts data error");
				}
			});
		},

		

		/**
		 * 初始化总电压图表
		 * @return {[type]} [description]
		 */
		_initTotalVolEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getVolData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "总电压";
					var legendData = ["总电压"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "总电压(V)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: '总电压',
						type: 'line',
						markPoint: {
							data: [{
								type: 'max',
								name: '最大值'
							}, {
								type: 'min',
								name: '最小值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._echartsConfig2(title, legendData, '',xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}V');
				},
				'error': function(msg) {
					console.log("init vol echarts data error");
				}
			});
		},

		/**
		 * 初始化单体最高电压图表
		 * @return {[type]} [description]
		 */
		_initMaxVolEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getMaxVolData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "单体最高电压";
					var legendData = ["单体最高电压"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "单体最高电压(V)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: '单体最高电压',
						type: 'line',
						markPoint: {
							data: [{
								type: 'max',
								name: '最大值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._echartsConfig2(title, legendData, '',xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}V');
				},
				'error': function(msg) {
					console.log("init MaxVol echarts data error");
				}
			});
		},

		/**
		 * 初始化单体最低电压图表
		 * @return {[type]} [description]
		 */
		_initMinVolEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getMinVolData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "单体最低电压";
					var legendData = ["单体最低电压"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "单体最低电压(V)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: '单体最低电压',
						type: 'line',
						markPoint: {
							data: [{
								type: 'min',
								name: '最小值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._echartsConfig2(title, legendData, '',xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}V');
				},
				'error': function(msg) {
					console.log("init MinVol echarts data error");
				}
			});
		},

		/**
		 * 初始化单体最高电压图表
		 * @return {[type]} [description]
		 */
		_initMaxTempEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getMaxTempData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "监测点最高温度";
					var legendData = ["监测点最高温度"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "监测点最高温度(℃)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: '监测点最高温度',
						type: 'line',
						markPoint: {
							data: [{
								type: 'max',
								name: '最大值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._echartsConfig(title, legendData, '',xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}℃');
				},
				'error': function(msg) {
					console.log("init MaxTemp echarts data error");
				}
			});
		},

		/**
		 * 初始化单体最低电压图表
		 * @return {[type]} [description]
		 */
		_initMinTempEcharts: function(myChart) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getMinTempData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var title = "监测点最低温度";
					var legendData = ["监测点最低温度"];
					var xAxisData = new Array();
					if(data.xAxisData){
						xAxisData.push(data.xAxisData);
					}
					var yAxisName = "监测点最低温度(℃)";
					var seriesData = new Array();
					if(data.seriesData){
						seriesData.push(data.seriesData);
					}
					var series = [{
						name: '监测点最低温度',
						type: 'line',
						markPoint: {
							data: [{
								type: 'min',
								name: '最小值'
							}]
						},
						data: seriesData
					}];
					realtimeBoard._echartsConfig(title, legendData,'',xAxisData, yAxisName, series, myChart,'{b}<br/>{a} : {c}℃');
				},
				'error': function(msg) {
					console.log("init MinTemp echarts data error");
				}
			});
		},


		/**
		 * [_setRealtimeEcharts description]
		 * @param {[type]} myChart   [echart实例]
		 * @param {[type]} url       [获取参数url]
		 * @param {[type]} magicType [echart显示类型:"line"，"bar"]
		 */
		_setRealtimeEcharts : function (myChart,url) {
			var packCode = $("#packCode").text();
			$.ajax({
				'type': 'post',
				'url': url,
				'dataType': 'json',
				"cache": false,
				'async': true,
				'data': {
					'packCode': packCode
				},
				'success': function(data) {
					var option = myChart.getOption();
					var xAxis_data = option.xAxis[0].data;
					if(data.xAxisData!=xAxis_data[xAxis_data.length-1]){
						xAxis_data.push(data.xAxisData);
						if(xAxis_data.length>10){
							xAxis_data.shift();
						}
						option.xAxis[0].data = xAxis_data;
						var series_data = option.series[0].data;
						series_data.push(data.seriesData);
						if(series_data.length>10){
							series_data.shift();
						}
						option.series[0].data = series_data;
						myChart.setOption(option);
					}
				},
				'error': function(msg) {
					console.log("get real-time data error");
				}
			});
		},

		/**
		 * [_initBoard 根据看板类型初始化看板]
		 * @param  {[boolean]} isinit         [是否需要初始化:暂停看板后启动不需要初始化看板]
		 * @param  {[type]} boardType         [看板类型]
		 * @param  {[type]} board             [如果是百度地图bmap，则参数类型为div_id.若为echart，则参数类型为echart实例]
		 * @param  {[type]} boardRefreshTimer [定时器]
		 * @return {[type]}                   [返回定时器对象]
		 */
		_initBoard:function(isinit,boardType,board,boardRefreshTimer) { 
			//判断看板类型是地图还是echart
			//echart需初始化
			console.log("初始化看板");
			switch (boardType) {
				case "0":
					if(isinit){
						realtimeBoard._getRealtimeLocation(board);
					}
					//启动定时器
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._getRealtimeLocation(board);
					},10000);
					return boardRefreshTimer;
				case "1":
					if(isinit){
						realtimeBoard._initSocEcharts(board);
					}
					//启动定时器
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getSocData.mvc");
					},5000);
					return boardRefreshTimer;
				case "2":
					if(isinit){
						realtimeBoard._initTotalVolEcharts(board);
					}
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getVolData.mvc");
					},5000);
					return boardRefreshTimer;
				case "3":
					if(isinit){
						realtimeBoard._initCurrentEcharts(board);
					}
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getCurrentData.mvc");
					},5000);
					return boardRefreshTimer;
				case "4":
					if(isinit){
						realtimeBoard._initMaxVolEcharts(board);
					}
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getMaxVolData.mvc");
					},5000);
					return boardRefreshTimer;
				case "5":
					if(isinit){
						realtimeBoard._initMinVolEcharts(board);
					}
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getMinVolData.mvc");
					},5000);
					return boardRefreshTimer;
				case "6":
					if(isinit){
						realtimeBoard._initMaxTempEcharts(board);
					}
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getMaxTempData.mvc");
					},5000);
					return boardRefreshTimer;
				case "7":
					if(isinit){
						realtimeBoard._initMinTempEcharts(board);
					}
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getMinTempData.mvc");
					},5000);
					return boardRefreshTimer;
				default:
					if(isinit){
						realtimeBoard._initSocEcharts(board);
					}
					//启动定时器
					boardRefreshTimer = window.setInterval(function(){
						realtimeBoard._setRealtimeEcharts(board,"main/realtimeBoard/getSocData.mvc");
					},5000);
					return boardRefreshTimer;
			}

		},


		_getPackCodeList : function () {
			$.ajax({
				'type': 'post',
				'url': 'main/realtimeBoard/getPackCodeData.mvc',
				'dataType': 'json',
				"cache": false,
				'async': false,
				'success': function(data) {
					if(data&&data.length>0){
						for (var i = 0; i < data.length; i++) {
							packCodeArr.push(data[i].packCode+","+data[i].colClientId);
						}
					$("#packCode").text(packCodeArr[0].split(",")[0]);
					$("#packCode").attr('data-colclientid',packCodeArr[0].split(",")[1]);
					}
				},
				'error': function(msg) {
					console.log("get packCodeList data error");
				}
			});
		}



	};

}();